Don't get and release the context for each point, just once, speeds up
authorRichard Hult <richard@imendio.com>
Mon, 7 Aug 2006 16:45:16 +0000 (16:45 +0000)
committerRichard Hult <rhult@src.gnome.org>
Mon, 7 Aug 2006 16:45:16 +0000 (16:45 +0000)
2006-08-07  Richard Hult  <richard@imendio.com>

* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
get and release the context for each point, just once, speeds up
drawing many points a lot.

ChangeLog
ChangeLog.pre-2-10
gdk/quartz/gdkdrawable-quartz.c

index 0d0391d99f2882161dcda8b679849a2d1dcedec0..fe30f5f1ce1085e66b726c1db07914f73a534800 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-07  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
+       get and release the context for each point, just once, speeds up
+       drawing many points a lot.
+
 2006-08-07  Michael Natterer  <mitch@imendio.com>
 
        * gtk/gtkdnd-quartz.c (gtk_drag_dest_unset): need to disconnect
index 0d0391d99f2882161dcda8b679849a2d1dcedec0..fe30f5f1ce1085e66b726c1db07914f73a534800 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-07  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
+       get and release the context for each point, just once, speeds up
+       drawing many points a lot.
+
 2006-08-07  Michael Natterer  <mitch@imendio.com>
 
        * gtk/gtkdnd-quartz.c (gtk_drag_dest_unset): need to disconnect
index f25626255554a4ba9661043f11fa990e8c43df36..94b68c8e36804e7f898565759e5789551ddb1884 100644 (file)
@@ -326,15 +326,24 @@ gdk_quartz_draw_points (GdkDrawable *drawable,
                       GdkPoint    *points,
                       gint         npoints)
 {
+  CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
   int i;
 
+  if (!context)
+    return;
+
+  gdk_quartz_update_context_from_gc (context, gc);
+  gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+                                               _gdk_gc_get_fg_pixel (gc));
+
   /* Just draw 1x1 rectangles */
   for (i = 0; i < npoints; i++) 
     {
-      gdk_draw_rectangle (drawable, gc, TRUE, 
-                         points[i].x, points[i].y,
-                         1, 1);
+      CGRect rect = CGRectMake (points[i].x + 0.5, points[i].y + 0.5, 1, 1);
+      CGContextFillRect (context, rect);
     }
+
+  gdk_quartz_drawable_release_context (drawable, context);
 }
 
 static void